<?php
error_reporting(E_ALL^ E_NOTICE);
ini_set('display_errors','On');


$username="ima";
$password= "ima2006";

/****************start updating data********************/
$link='http://huarenads.com/images/listings/3_thumb.jpg';
$link='http://www.mathinstitutes.org/images/protein_thumb.jpg';
$ch = curl_init();
 
curl_setopt($ch, CURLOPT_POST, 0);
 
curl_setopt($ch,CURLOPT_URL,$link);
 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 
$image=curl_exec($ch);
 
curl_close($ch);
$image = strtr(base64_encode(addslashes(gzcompress(serialize($image),9))), '+/=', '-_,');
$lectureDate = strtotime(date('2013-06-08 14:00:00'));
$data =  array(
				"title" => "Dooes Neuroscience Need Mathematics testing", 
			  "lectureDate"=> "$lectureDate",
				"duration"=> "600",
			  "remoteURL" => "http://google.com/",
			  "location" => "Mathematics Bioscience Institute",
				"eventTitle" => "Testing api", 
			  "presenters" => array( "familyName" => "Cui" ,"givenName" => "Qing",
				"title" => "Professor",
				"company" => "test company"),
				"keywords" => array("Maths","testing"),
				"mscNumbers" => array("3333","9999"),
				"timecode" => array(array("timecode"=>100,
				"timecode_type" => "Slide",
				"data" =>"Modeling in Ecology"),array("timecode"=>15,
				"timecode_type" => "Slide2",
				"data" =>"Modeling in Ecology2")),
				"rating" =>2,
				"thumbnail" => array("image" => $image, "type"=>"jpg")
			  );                                                                         
$data_string = "json=".json_encode($data); 
$ch = curl_init("http://www.mathinstitutes.org/math-videos/metadata/v1/asset/"); //insert

$options = array(
  CURLOPT_POST => 1,
  CURLOPT_RETURNTRANSFER => true,
	CURLOPT_HEADER => false,   //true or false to show header in result
  CURLOPT_POSTFIELDS => $data_string,
 CURLOPT_USERPWD=>"$username:$password");

// Setting curl options
curl_setopt_array( $ch, $options ); 
$result = curl_exec($ch);
curl_close($ch);
echo $result;
$obj=json_decode($result);
print_r($obj);
?>